home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Make a file from a message as an action (not a command) *)
- (* *)
- (* Copyright 1990, 1992 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE do_make_file;
-
- VAR
- kill_sw : BOOLEAN;
- search_info : search_block_type;
- this_msg : msg_index_ptr;
- to_this_file : file_name_str;
- write_mode : BYTE;
-
- LABEL
- do_next_file;
-
- BEGIN;
-
- kill_sw := POS('K', options_str) <> 0;
-
- (*-----------------------------------------------------------------------*)
- (* Save the name of the file pattern to use *)
- (*-----------------------------------------------------------------------*)
-
- to_this_file := s2;
-
- (*-----------------------------------------------------------------------*)
- (* Build the search arguement *)
- (*-----------------------------------------------------------------------*)
-
- set_search(s1, @search_info);
- IF active_tcb^.error_sw THEN
- BEGIN;
- send_tnc_data_str('Invalid search on action -- ' + s1 + cr);
- free_task_mem('MSB', TRUE);
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Prepare to do the search *)
- (*-----------------------------------------------------------------------*)
-
- search_info.search_last := NIL;
- search_info.search_nok := FALSE;
-
- GOTO do_next_file;
-
- (*-----------------------------------------------------------------------*)
- (* Search loop *)
- (*-----------------------------------------------------------------------*)
-
- REPEAT
-
- (*---------------------------------------------------------------------*)
- (* Put msg pointer somewhere handy *)
- (*---------------------------------------------------------------------*)
-
- this_msg := search_info.search_last;
-
- (*---------------------------------------------------------------------*)
- (* If this message already archived then skip it *)
- (*---------------------------------------------------------------------*)
-
- IF (this_msg^.msg_i_mb.msg_flag AND mf_archive) <> 0 THEN
- GOTO do_next_file;
-
- (*---------------------------------------------------------------------*)
- (* Build the file name by putting the current msg info to the right *)
- (* spot and translating the file name pattern into a real file name *)
- (*---------------------------------------------------------------------*)
-
- s2 := to_this_file;
-
- active_tcb^.curr_msg := this_msg^;
-
- substitute_line(s2);
-
- (*---------------------------------------------------------------------*)
- (* Convert the file *)
- (*---------------------------------------------------------------------*)
-
- IF action_word = 'MAKE_FILE_REPLACE' THEN
- write_mode := 1
- ELSE
- IF action_word = 'MAKE_FILE_APPEND' THEN
- write_mode := 2
- ELSE
- write_mode := 0;
-
- (*---------------------------------------------------------------------*)
- (* Convert the file *)
- (*---------------------------------------------------------------------*)
-
- read_a_msg(this_msg, s2, write_mode, FALSE, TRUE);
-
- (*---------------------------------------------------------------------*)
- (* Get ready to give message *)
- (*---------------------------------------------------------------------*)
-
- STR(this_msg^.msg_i_mb.msg_number, s1);
-
- (*---------------------------------------------------------------------*)
- (* If we failed, send the failed message *)
- (*---------------------------------------------------------------------*)
-
- IF active_tcb^.error_sw THEN
- BEGIN;
- send_tnc_data_str('Attempt to convert message ' + s1
- + ' to file ' + s2 + ' failed' + cr);
- GOTO do_next_file;
-
- END;
-
- (*---------------------------------------------------------------------*)
- (* If we succeeded, update the archive flag *)
- (*---------------------------------------------------------------------*)
-
- this_msg^.msg_i_mb.msg_flag := this_msg^.msg_i_mb.msg_flag OR mf_archive;
-
- update_msg(this_msg);
-
- (*---------------------------------------------------------------------*)
- (* Tell user we succeeded *)
- (*---------------------------------------------------------------------*)
-
- send_tnc_data_str('Message ' + s1 + ' converted to file ' + s2 + cr);
-
- (*---------------------------------------------------------------------*)
- (* Kill? *)
- (*---------------------------------------------------------------------*)
-
- IF kill_sw AND NOT active_tcb^.error_sw THEN
- kill_a_msg(this_msg, TRUE);
-
- (*---------------------------------------------------------------------*)
- (* Conduct next search *)
- (*---------------------------------------------------------------------*)
-
- do_next_file:
-
- search_msg(@search_info);
-
- UNTIL search_info.search_last = NIL; (*----- End of search loop ---------*)
-
- (*-----------------------------------------------------------------------*)
- (* Free any left over memory *)
- (*-----------------------------------------------------------------------*)
-
- free_task_mem('MSB', TRUE);
-
- (*-----------------------------------------------------------------------*)
- (* Leave some time *)
- (*-----------------------------------------------------------------------*)
-
- task_switch;
-
- END;